<div>
    <script></script>
    <fieldset>
        <legend>Управление изданиями</legend>

        <div class="PageMenu">
            <button id="AddEdition">Новое издание</button>
            <div style="margin-top: 1em;">Выбирите издание</div>
            <?php echo $this->EditTypes("EditType", true)->ToHtml(); ?>
            <input type="text" id="SearchVal" class="Wide Text"/>
            <button id="FindEdit">Найти</button>
        </div>

        <div id="SearchResult"></div>
    </fieldset>

    <script type="text/javascript">
        jsun.run(function() {

        jsun("#FindEdit").jsun.event({ onclick: Search });
        jsun("#AddEdition").jsun.event({ onclick: AddEdition });

        function Search() {
            var client = jsun("#SearchResult"),
                param = "u=Lib&m=Lib\\Edition/SearchResult"
                    + "&EditType=" + jsun("#EditType").value
                    + "&SearchVal=" + jsun("#SearchVal").value;

            jsun.json.load(function(p) {
                client.innerHTML = "";
                client.appendChild(jsun.dom.from_json(p.content));

                var links = jsun("#SearchTable").childNodes;
                for (var i = 1; i < links.length; ++i) {
                    jsun.dom.mix(links[i].childNodes[2].firstChild).event({ onclick: AddDialog });
                }
            }, param);
        }

        function AddEdition() {
            window.location.href = "?u=Lib&p=Lib\\Edition/Add";
        }

        function AddDialog() {
            var dlg = new jsun.dialog({ width: 600, title: "Добавить экземпляр" });

            jsun.html.insert(dlg.content.v, jsun.html.sync_load(
                "u=Lib&m=Lib\\Edition/AddItem&edit_id="
                    + this.parentNode.parentNode.getAttribute("data-edit")));
            return dlg.show();
        }

        });
    </script>
</div>